//
//  MGJRouterManager.m
//  OCStudy
//
//  Created by tomato on 2022/8/12.
//

#import "MGJRouterManager.h"
#import "LuYouTestVC.h"
#import "TMDNavigationController.h"
#import "LuYouVC.h"

@implementation MGJRouterManager

+(void)load{

    //不带参数跳转
    [MGJRouter registerURLPattern:@"tmd://test/pushToVC" toHandler:^(NSDictionary *routerParameters) {
        
        NSLog(@"MGJRouter参数:%@", routerParameters[MGJRouterParameterUserInfo]);
        
        TMDNavigationController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        LuYouTestVC *vc = [[LuYouTestVC alloc] init];
        [navigationVC pushViewController:vc animated:YES];
    }];
    
    //带参数跳转
    [MGJRouter registerURLPattern:@"tmd://test/pushToVCWithCanShu" toHandler:^(NSDictionary *routerParameters) {
        
        NSString *userPhone = routerParameters[MGJRouterParameterUserInfo][@"userPhone"];
        TMDNavigationController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        LuYouTestVC *vc = [[LuYouTestVC alloc] init];
        vc.userPhone = userPhone;
        [navigationVC pushViewController:vc animated:YES];
    }];
    
    
    [MGJRouter registerURLPattern:@"tmd://test/getTestVC" toObjectHandler:^id(NSDictionary *routerParameters) {
        NSString *labelText = routerParameters[MGJRouterParameterUserInfo][@"userPhone"];
        LuYouTestVC *vc = [[LuYouTestVC alloc] init];
        vc.userPhone = labelText;
        return vc;
    }];
    
    //反向传值
    [MGJRouter registerURLPattern:@"tmd://test/fanXiangChuanZhi" toHandler:^(NSDictionary *routerParameters) {
        
        TMDNavigationController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NSString *userName = routerParameters[MGJRouterParameterUserInfo][@"userName"];
    }];
   
}



@end
